from core.map import *
from core.graph import MapRenderer
from core.config import Configuration
import os, sys, logging, pygame
 
def main():
    if len(sys.argv) < 3:
        print 'Usage %s path/to/config.ini path/to/map.xml' % sys.argv[0]
        return 1
    
    print 'Reading config from %s' % sys.argv[1]
    config = Configuration(sys.argv[1])
    
    pygame.init()
    screen = pygame.display.set_mode((int(config.display.width), int(config.display.height)))
    pygame.display.set_caption('Galaxy')
    pygame.mouse.set_visible(1)
    
    print 'Reading map from %s' % sys.argv[2]
    mapfile = open( sys.argv[2] )
    
    cn = mapfile.readlines()
    map = Map(cn, config)
    rd = MapRenderer(map, screen, config)
    rd.loop()

if __name__ == '__main__':
    sys.exit(main())